// smartlogistics/pages/smartLogistics/smartLogistics.js
const _wx = require('../../../utils/util.js');
Page({
  /**
   * 页面的初始数据
   */
  data: {
    limit: 3,
    warnlist: [],
    goodWarnList: [],
    rankList: [],
    device:[],
    count: 0,
    orderCount: 0,
    goodWarnCount: 0,
    warnCount: 0,
    retCount: 0,
    active: 0,
    icon: {
      active: 'https://m.bjclb.cn/assets/tabbar1.png',
      normal: 'https://m.bjclb.cn/assets/tabbar1x.png',
    },
    icon2: {
      active: 'https://m.bjclb.cn/assets/tabbar2.png',
      normal: 'https://m.bjclb.cn/assets/tabbar2x.png',
    },
    icon3: {
      active: 'https://m.bjclb.cn/assets/tabbar3.png',
      normal: 'https://m.bjclb.cn/assets/tabbar3x.png',
    },
  },
  asd() {
    const that = this
    _wx.getData('/admin/warehouse/statistics/index', 'GET', {}, function (res) {
      if (res.code == 0) {
        that.setData({
          count: res.data.count
        })
        that.setData({
          orderCount: res.data.orderCount
        })
        that.setData({
          goodWarnCount: res.data.goodWarnCount
        })
        that.setData({
          warnCount: res.data.warnCount
        })
        that.setData({
          retCount: res.data.retCount
        })
        that.setData({
          goodWarnList: res.data.goodWarnList
        })
        that.setData({
          rankList: res.data.rankList
        })
      }
    });
  },
  warningSelect() {
    const that = this
    _wx.getData('admin/warehouse/warehousewarn/select', 'GET', {
      limit: this.data.limit
    }, function (res) {
      if (res.code == 0) {
        that.setData({
          warnlist: res.data
        })

      } else {
        console.log(res.msg);
      }
    });
  },
  toolsguanli(){
    const that = this
    _wx.getData('admin/warehouse/warehousecabinet/select', 'GET', {
     limit:4
    }, function (res) {
      if (res.code == 0) {
    that.setData({device:res.data})

      } else {
        console.log(res.msg);
      }
    });
  },
  onChange(event) {
    this.setData({
      active: event.detail
    });
  },
  handlepush: function () {
    wx.redirectTo({
      url: '../../pages/warehousingitems/warehousingitems',
    })
  },
  handlepushto: function () {
    wx.redirectTo({
      url: '../../pages/warehousemanagement/warehousemanagement',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // this.asd()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.asd();
    this.warningSelect();
    this.toolsguanli()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  // 跳转到报警记录
  handlemore: function () {
    wx.navigateTo({
      url: '../../pages/warnlog/warnlog',
    })
  },
  // 跳转到排行榜
  handlemoreto: function () {
    wx.navigateTo({
      url: '../../pages/goodstop/goodstop',
    })
  }
})